package org.kl.bf.repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Selection;

import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

/**
 * 自定义Repository
 * 
 * @Author hqm
 * @CreateTime 2014-3-14 下午5:01:47
 */
@NoRepositoryBean
public interface BasicRepository<T extends Serializable, ID extends Serializable> extends JpaRepository<T, ID> {
	<S extends T> S save(S entity);

	T find(Class<T> clazz, Object pk);

	T sumByKLSearchFilter(CriteriaQuery<T> criteriaQuery, Predicate[] predicates, Selection<?>... selections);

	EntityManager getEntityManager();

	CriteriaBuilder getCriteriaBuilder();
	
	Page<T> getPage(Map<String, Object> searchParams,int pageNumber, int pageSize, String sortType, String orderType,Class<T> clazz);
	List<T> searchAll(Map<String, Object> searchParams,Class<T> clazz);
	List<T> searchAll(Map<String, Object> searchParams,String sortType, String orderType,Class<T> clazz);
	
	T footerByKLSearchFilter(CriteriaQuery<T> criteriaQuery, Predicate[] predicates, Selection<?>... selections);
}
